<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Permission extends Model
{
    protected $table = 'permissions';

    protected $fillable = [
    	'identity',
    	'desc',
    	'uri',
    	'methed'
    ];

    protected $appends = [
    	'methed_desc'
    ];

    const METHED_ALL = 0;

    const METHED_GET = 1;

    const METHED_POST = 2;

    const METHED_PUT = 3;

    const METHED_DELETE = 4;

    public static $METHED = [
    	self::METHED_ALL => 'ALL',
    	self::METHED_GET => 'GET',
    	self::METHED_POST => 'POST',
    	self::METHED_PUT => 'PUT',
    	self::METHED_DELETE => 'DELETE'
    ];

    public function getMethedDescAttribute(){
    	if(array_key_exists('methed', $this->attributes)){
    		return $this->attributes['methed_desc'] = self::$METHED[$this->attributes['methed']];
    	}
    }
}
